Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix init_parser_plugins for python 3.12 #425

Closed
wants to merge 2 commits into from
Closed

fix init_parser_plugins for python 3.12 #425

wants to merge 2 commits into from

Conversation

cghyzel
Copy link
Contributor

@cghyzel cghyzel commented May 19, 2024

Hotfix for users on python 3.12, which broke because the entry points no longer return as a dictionary in that version, so .select(group='lute.plugin.parse') is used instead.

Additional logic was added to handle version differences, both in terms of fetching the entry points from the method and processing them (a catch for None was added)

Solves:

reformatted the ValueError in init_parser_plugins to conform with black's formatting standard
Copy link
Collaborator

@jzohrab jzohrab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much! You've probably gone to bed so I'll take the PR and make the changes to it, and then merge it. Appreciated!


if version_info.major == 3 and version_info.minor in (8, 9, 10, 11):
custom_parser_eps = entry_points().get('lute.plugin.parse')
elif version_info.major == 3 and version_info.minor == 12:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should change this to >= 12. Granted, we can't know what the API will be in version 3.13+, but maybe we can play fast and loose with this one, and just bump up the CI checks on GitHub as versions come out.

for custom_parser_ep in custom_parser_eps:
if _is_valid(custom_parser_ep.load()):
__LUTE_PARSERS__[custom_parser_ep.name] = custom_parser_ep.load()
else:
raise ValueError(
f"{custom_parser_ep.name} is not a subclass of AbstractParser"
f"{custom_parser_ep.name} is not a a subclass of AbstractParser"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the "a a" before, and here it's added again, any reason? :-)

@jzohrab
Copy link
Collaborator

jzohrab commented May 19, 2024

Code included in updated #426 , cheers!

@jzohrab jzohrab closed this May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants